from flask import Flask,render_template,request,jsonify

app=Flask(__name__) # Flask

@app.route("/") # route不能改，index可以改但不建议
def index():
    return render_template("test.html") # 填网页名称

@app.route("/test")
def test():
    return "哈哈哈"

@app.route("/predict",methods=['POST'])
def predict1():
    result1 = request.get_json() # 获取前端表单
    a1 = float(result1['feature1'])
    a2 = float(result1['feature2'])
    a3 = float(result1['feature3'])
    final = a1 + a2 + a3
    print(final)
    return jsonify({"predict":final}) # 适合阅读

@app.route("/test1135",methods=['GET'])
def test1():
    A =request.args.get("xxxx")
    return A
    
app.run(host="0.0.0.0",port=5000,debug=True) # host="127.0.0.1” 只能在本地电脑打开
                                               # host="0.0.0.0“ 别人能看到
                                               # ”5000“可以改，一般练习用，不冲突即可
                                               # debug=Ture,保存后重启，防止端口冲突
